package com.example.teacher.Controller;

import com.example.common.domain.Result;
import com.example.teacher.Service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "老师端接口", description = "删除ai生成数据")
@RestController
@RefreshScope//时时刷新配置信息
@Slf4j  //日志  log.info("登录日志测试：");
@RequestMapping("/teachers")
@RequiredArgsConstructor
public class AiDeleteController {
    @Autowired
    private QuestionService questionService;
    @Autowired
    private HomeworkService homeworkService;
    @Autowired
    private PPTService pptService;
    @Autowired
    private HandoutsService handoutsService;
    @Autowired
    private SectionService sectionService;
    @Autowired
    private ExperimentService experimentService;
    @Autowired
    private RethinkService rethinkService;

    @ApiOperation("删除题目")
    @PostMapping("/deleteQuestion/{id}")
    public Result<String> deleteQuestion(@PathVariable String id) {
        return questionService.removeById(id) ? Result.success() : Result.error("删除失败");
    }

    @ApiOperation("批量删除题目")
    @PostMapping("/deleteQuestions")
    public Result<String> deleteQuestions(@RequestBody List<String> ids) {
        return questionService.removeByIds(ids) ? Result.success() : Result.error("删除失败");
    }

    @ApiOperation("删除作业")
    @PostMapping("/deleteHomework/{id}")
    public Result<String> deleteHomework(@PathVariable String id) {
        return homeworkService.removeById(id) ? Result.success() : Result.error("删除失败");
    }

    @ApiOperation("批量删除作业")
    @PostMapping("/deleteHomeworkBatch")
    public Result<String> deleteHomeworkBatch(@RequestBody List<String> ids) {
        return homeworkService.removeByIds(ids) ? Result.success() : Result.error("删除失败");
    }

    @ApiOperation("删除小节")
    @PostMapping("/deleteSection/{id}")
    public Result<String> deleteSection(@PathVariable String id) {
        return sectionService.removeById(id) ? Result.success() : Result.error("删除失败");
    }

    @ApiOperation("批量删除小节")
    @PostMapping("/deleteSectionBatch")
    public Result<String> deleteSectionBatch(@RequestBody List<String> ids) {
        return sectionService.removeByIds(ids) ? Result.success() : Result.error("删除失败");
    }

    @ApiOperation("删除PPT")
    @PostMapping("/deletePPT/{id}")
    public Result<String> deletePPT(@PathVariable String id) {
        return pptService.removeById(id) ? Result.success() : Result.error("删除失败");
    }

    @ApiOperation("批量删除PPT")
    @PostMapping("/deletePPTs")
    public Result<String> deletePPTs(@RequestBody List<String> ids) {
        return pptService.removeByIds(ids) ? Result.success() : Result.error("删除失败");
    }

    @ApiOperation("删除讲义")
    @PostMapping("/deleteHandouts/{id}")
    public Result<String> deleteHandouts(@PathVariable String id) {
        return handoutsService.removeById(id) ? Result.success() : Result.error("删除失败");
    }

    @ApiOperation("批量删除讲义")
    @PostMapping("/deleteHandoutsBatch")
    public Result<String> deleteHandoutsBatch(@RequestBody List<String> ids) {
        return handoutsService.removeByIds(ids) ? Result.success() : Result.error("删除失败");
    }

    @ApiOperation("删除实验")
    @PostMapping("/deleteExperiment/{id}")
    public Result<String> deleteExperiment(@PathVariable String id) {
        return experimentService.removeById(id) ? Result.success() : Result.error("删除失败");
    }

    @ApiOperation("批量删除实验")
    @PostMapping("/deleteExperiments")
    public Result<String> deleteExperiments(@RequestBody List<String> ids) {
        return experimentService.removeByIds(ids) ? Result.success() : Result.error("删除失败");
    }

    @ApiOperation("删除老师反思")
    @PostMapping("/deleteRethink/{id}")
    public Result<String> deleteRethink(@PathVariable String id) {
        return rethinkService.removeById(id) ? Result.success() : Result.error("删除失败");
    }


}
